<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app">
    <p>欢迎来到_vue开发的收银系统_水果店</p>
    <p><b>苹果 10元/斤，打八折</b></p>
    请输入你要购买的斤数<input type="number" v-model.number="count"><br>
    <button @click="fn">结账买单</button><br>
    <p>结账单：总价：{{total}}元， 折扣后：{{apply}}元，省了：{{reduce}}元</p>
  </div>

  <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
  <script>
    new Vue({
      el: '#app',
      data: {
        count: 0,
        total: 0,
        apply: 0,
        reduce: 0
      },
      methods: {
        fn() {
          this.total = this.count * 10
          this.apply = this.count * 10 * .8
          this.reduce = this.total - this.apply
        }
      },
      /*       computed: {
              total() {
                return this.count * 10
              },
              apply() {
                return this.count * 10 * .8
              },
              reduce() {
                return this.total - this.apply
              }
            } */
    })
  </script>
</body>

</html>